package com.Home.digital_life;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.Toast;

public class MainActivity extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	
		/*String localIP = null;
		final String url="192.168.1.100";
		final int port=5000;
		final byte commond[]={8,0};
		try {
			Toast.makeText(MainActivity.this, "正在连接...", Toast.LENGTH_SHORT).show();
			localIP=GetLocalIP.getLocalIpAddress();
			Upload.TcpRun(url, port, commond, localIP.getBytes());
			Toast.makeText(MainActivity.this, "开始", Toast.LENGTH_SHORT).show();
		} catch (SocketException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		
		GridView gridview = (GridView) findViewById(R.id.gridview);
		gridview.setAdapter(new ImageAdapter(this));
		
		

		gridview.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View v,
					int position, long id) {
				// TODO Auto-generated method stub
				switch (position) {
				case 0:
					Toast.makeText(MainActivity.this, "音乐", Toast.LENGTH_SHORT)
							.show();
					Intent intent0 = new Intent();
					intent0.setClass(MainActivity.this, MusicActivity.class);
					startActivity(intent0);
					break;
				case 1:
					Toast.makeText(MainActivity.this, "视频", Toast.LENGTH_SHORT)
							.show();
					Intent intent1 = new Intent();
					intent1.setClass(MainActivity.this, VideoActivity.class);
					startActivity(intent1);
					break;
				case 2:
					Toast.makeText(MainActivity.this, "备份还原联系人",
							Toast.LENGTH_SHORT).show();
					Intent intent2 = new Intent();
					intent2.setClass(MainActivity.this,
							ContactPersonActivity.class);
					startActivity(intent2);
					break;
				case 3:
					Toast.makeText(MainActivity.this, "备份还原短信",
							Toast.LENGTH_SHORT).show();
					Intent intent3 = new Intent();
					intent3.setClass(MainActivity.this, MessageActivity.class);
					startActivity(intent3);
					break;
				case 4:
					Toast.makeText(MainActivity.this, "更新媒体列表",
							Toast.LENGTH_SHORT).show();
					Intent intent4 = new Intent();
					intent4.setClass(MainActivity.this, UpdateActivity.class);
					startActivity(intent4);
					break;
				case 5:
					Toast.makeText(MainActivity.this, "设置", Toast.LENGTH_SHORT)
							.show();
					Intent intent5 = new Intent();
					intent5.setClass(MainActivity.this, SetActivity.class);
					startActivity(intent5);
					break;
				case 6:
					Toast.makeText(MainActivity.this, "关于...",
							Toast.LENGTH_SHORT).show();
					Intent intent6 = new Intent();
					intent6.setClass(MainActivity.this, AboutActivity.class);
					startActivity(intent6);
					break;
				case 7:
					Toast.makeText(MainActivity.this, "退出", Toast.LENGTH_SHORT)
							.show();
					finish();
					break;
				}
			}
		});
		
	}

}
